﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace JGSY.CMS.LowCode.Platform.Migrations
{
    /// <inheritdoc />
    public partial class AddWorkflowVersioningUniqAndConcurrency : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<byte[]>(
                name: "RowVersion",
                table: "Workflows",
                type: "bytea",
                rowVersion: true,
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_workflow_versions_WorkflowId_Version",
                table: "workflow_versions",
                columns: new[] { "WorkflowId", "Version" },
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_workflow_versions_WorkflowId_Version",
                table: "workflow_versions");

            migrationBuilder.DropColumn(
                name: "RowVersion",
                table: "Workflows");
        }
    }
}
